interface CreateIndexsType {
  name: string;
  value: string;
  unique: boolean;
}
interface ObjectStoreType {
  name: string;
  autoIncrement?: boolean;
  keyPath?: string;
  createIndexs?: CreateIndexsType[];
}

interface IndexedDBSettingsType {
  databaseName: string;
  version: number;
  objectStore: ObjectStoreType[];
}

interface DBRes {
  data?: any;
  code: number;
  message: string;
}
type PermissionType = "readonly" | "readwrite";

/**
 * data @param
 * @新增时 为新增数据
 * @读取时 { indexName,index }  indexName 为索引条件，不填使用主键 index为索引值
 */
interface OptionsDataType {
  indexName?: string;
  index: number | string;
}
interface OptionsType {
  name: string;
  data: OptionsDataType | any;
  permission: PermissionType;
}

const indexedDBSettings: IndexedDBSettingsType = {
  databaseName: "EWG_DB",
  version: 1,
  objectStore: [
    {
      name: "equip",
      autoIncrement: true,
      createIndexs: [
        {
          name: "uuid",
          value: "uuid",
          unique: true
        }
      ]
    }
  ]
};
export { indexedDBSettings, DBRes, OptionsType, OptionsDataType };
